{include file="public/head"}
<div class="main">
    {include file="public/left"}
    <div class="middle">
    {include file="public/header"}
    <div class="high_search">
        <p>
            <span>{:__('项目标题')}：</span>
            <input id="title" class="layui-input" type="text"/>
        </p>
        <p>
            <span>{:__('项目分类')}：</span>
            <select class="layui-input" id="mission_category">
                <option value="-1">{:__('全部')}</option>
            </select>
        </p>
        <p>
            <span>{:__('当前状态')}：</span>
            <select class="layui-input" type="text" id="mission_hall_status">
                <option value="-1">{:__('全部')}</option>
            </select>
        </p>
        <p>
            <span>{:__('任务类型')}：</span>
            <select class="layui-input">
                <option value="-1">{:__('全部')}</option>
                <option>{:__('悬赏任务')}</option>
            </select>
        </p>
        <p>
            <span>{:__('任务金额')}：</span>
            <select id="intergralzone" class="layui-input">
                <option value="-1">{:__('全部')}</option>
            </select>
        </p>
        <p>
            <span>{:__('项目编号')}：</span>
            <input id="mission_no" class="layui-input" type="text"/>
        </p>
        <p>
            <span>{:__('中标模式')}：</span>
            <select class="layui-input" id="slt_bid_mode">
                <option value="-1">{:__('全部')}</option>
                <option value="1">{:__('单人中标')}</option>
                <option value="2">{:__('多人中标')}</option>
                <option value="3">{:__('计件中标')}</option>
            </select>
        </p>
        <p>
            <span>{:__('排序方式')}：</span>
            <select id="sort" class="layui-input" >
                <option value="-1">{:__('全部')}</option>
                <option value="money">{:__('悬赏')}</option>
                <option value="expire">{:__('到期时间')}</option>
                <option value="browse">{:__('浏览量')}</option>
            </select>
        </p>
        <p>
            <button id="search" class="layui-btn layui-btn-primary">{:__('搜索')}</button>
            <button id="reload" class="layui-btn layui-btn-primary">{:__('重置')}</button>
        </p>
    </div>
    <div class="high_class">
        <ul>
        </ul>
    </div>
    {include file="public/foot"}
    </div>
    {include file="public/right"}
</div>
{include file="public/footer"}
<script>
    var mission_category = getLocalStorage("mission_category");
    var intergralzone = getLocalStorage("intergralzone");
    var mission_hall_status = getLocalStorage("mission_hall_status");
    if(mission_category == '' || mission_category == null || mission_category == undefined ||
    intergralzone == '' || intergralzone == null || intergralzone == undefined ||
    mission_hall_status == '' || mission_hall_status == null || mission_hall_status == undefined 
    ){
        objs = {
            'mission_category':1,
            'intergralzone':1,
            'mission_hall_status':1
        }
        
        CacheLoad(objs);
        $(document).queue('mission_category,intergralzone,mission_hall_status,',function(){
            getmessiondata();
        });
    } else {
        getmessiondata();
    }


    function getmessiondata(){

        mission_category = getLocalStorage("mission_category");
        intergralzone = getLocalStorage("intergralzone");
        mission_hall_status = getLocalStorage("mission_hall_status");

        var htl = "";
        var optionhtl = "";
        var mission_categoryobj = JSON.parse(mission_category);
        for(i in mission_categoryobj){
            htl += "<h6><a href='/index/Index/tasklist?id="+i+"'>"+mission_categoryobj[i]['name']+"</a></h6>";
            optionhtl += "<option value='"+i+"'>"+mission_categoryobj[i]['name']+"</option>";
            for(j in mission_categoryobj[i]['_child']){
                htl += "<span><a href='/index/Index/tasklist?id="+mission_categoryobj[i]['_child'][j]['cat_id']+"'>"+mission_categoryobj[i]['_child'][j]['name']+"</a></span>";
            }
        }
        $(".high_class ul").html(htl);
        $("#mission_category").append(optionhtl);
        optionhtl = "";
        var intergralzoneobj = JSON.parse(intergralzone);
        for(j in intergralzoneobj){
            optionhtl += "<option value='"+j+"'>"+intergralzoneobj[j]+"</option>";
        }
        $("#intergralzone").append(optionhtl);
        optionhtl = "";
        var mission_hall_statusobj = JSON.parse(mission_hall_status);
        for(k in mission_hall_statusobj){
            optionhtl += "<option value='"+k+"'>"+mission_hall_statusobj[k]+"</option>";
        }
        $("#mission_hall_status").append(optionhtl);
    }

    $("#reload").click(function(){
        $("select").val("-1");
        $("input").val("");
    });

    $("#search").click(function(){
        var param = "";
        var title = $("#title").val();
        var mission_category = $("#mission_category").val();
        var mission_hall_status = $("#mission_hall_status").val();
        var intergralzone = $("#intergralzone").val();
        var mission_no = $("#mission_no").val();
        var slt_bid_mode = $("#slt_bid_mode").val();
        var sort = $("#sort").val();
        if(title != ''){
            param += 'title='+title+'&';
        }
        if(mission_category !=-1){
            param += 'id='+mission_category+'&';
        }
        if(mission_hall_status !=-1){
            param += 'mission_hall_status='+mission_hall_status+'&';
        }
        if(intergralzone !=-1){
            param += 'intergralzone='+intergralzone+'&';
        }
        if(mission_no !=''){
            param += 'mission_no='+mission_no+'&';
        }
        if(slt_bid_mode !=-1){
            param += 'slt_bid_mode='+slt_bid_mode+'&';
        }
        if(sort !=-1){
            param += 'sort='+sort+'&';
        }
        if(param !=''){
            param = '?'+param;
            var len = param.length;
            param = param.substr(0,parseInt(len)-1);
        }
        window.location.href="/index/Index/tasklist"+param;
    });
</script>